import React from 'react';
import ReactDom from 'react-dom';
import $ from 'webpack-zepto';
import Util from '../common/util.js';
import SellerForm from './view/seller-form.js';
import SellerList from './view/seller-list.js';

export default class Seller extends React.Component{

    static get defaultProps() {
        let appId = Util.appId();
        Util.storage().put(appId,Util.getUrlParam("uToken"));
        return {
            type : Util.getUrlParam('type'),
            appId : appId
        };
    };

    initState(){
        return {
            isAdd : null == this.props.type ? false : true
        };
    };

    constructor(props){
        super(props);
        this.state = this.initState();
    };

    render(){
        return (
            <div className="seller">
                {
                    this.state.isAdd?
                        <SellerForm appId={this.props.appId}></SellerForm>
                     :
                        <SellerList appId={this.props.appId}></SellerList>
                }
            </div>
        );
    };
}

ReactDom.render(
    <Seller></Seller>,
    $('#seller')[0]
);